module.exports = {
  presets: [
    [
      "@babel/preset-env",
      {
        // 浏览器兼容方案配置
        targets: {
          browsers: [">0.25%", "not ie 11", "not op_mini all"],
        },
      },
    ],
    "@babel/preset-react",
    "@babel/preset-typescript",
  ],
  env: {
    // 开发环境配置
    development: {
      presets: [["@babel/preset-react", { development: true }]],
    },
    // 生产环境配置
    production: {
      presets: ["@babel/preset-react"],
      plugins: ["@babel/plugin-transform-react-constant-elements", "@babel/plugin-transform-react-inline-elements"],
    },
  },
  plugins: [
    [
      "import",
      {
        libraryName: "antd",
        libraryDirectory: "es",
        style: "css",
      },
    ],
    [
      "@babel/plugin-transform-runtime",
      {
        corejs: 3,
        helpers: true,
        regenerator: true,
        useESModules: true,
      },
    ],
    [
      "@babel/plugin-proposal-decorators",
      {
        legacy: true,
      },
    ],
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-transform-async-to-generator",
    "@babel/plugin-proposal-object-rest-spread",
    "@babel/plugin-proposal-class-properties",
  ],
};
